package com.stream;

import com.alibaba.fastjson.JSONObject;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author:zxh
 * @Description: java.util.stream 熟悉
 * @Date: 2020/9/24
 * @Modified By:
 */
public class StreamTestOne {
    //1.Java 8 中首次出现的 java.util.stream 是一个函数式语言+多核时代综合影响的产物
    //2.在传统的 J2EE 应用中，Java 代码经常不得不依赖于关系型数据库的聚合操作来完成诸如：
    //@1客户每月平均消费金额,@2最昂贵的在售商品,@3.取十个数据样本作为首页推荐
    //原型

    static class ConstantStream{
         static   final Integer STATUS = 2;
    }
    public void one(){
        List<Student> studentListOne = new ArrayList<>();
        studentListOne.add(new Student("xiao","xiaoTwo",2,14));
        studentListOne.add(new Student("hu","huTwo",2,15));
        studentListOne.add(new Student("laoSan","laoSanTwo",20,25));

        List<Student> studentList = new ArrayList<>();
        for (Student student:studentListOne) {
            if (student.getAge() == ConstantStream.STATUS) {
                studentList.add(student);
            }
        }
    }

    public static void main(String[] args) {
        List<String> strList = new ArrayList<>(2);
        strList.add("23");strList.add("34"); strList.add("65");
        strList.forEach(ss -> {
            System.out.println(ss);
            if (ss.equals("34")) {
                return;
            }
            System.out.println();
        });

        String join = String.join(",", strList);
        String collect = strList.stream().collect(Collectors.joining(","));
        //strList.stream().collect();
        JSONObject jsonObjectMemberList = JSONObject.parseObject(null);
        JSONObject jsonObject = null;

        ArrayList<Student> students = new ArrayList<>();
        students.add(new Student("1","2",3,4));
        //es.getSpecialConditions().stream().map(BondSpecialConditionsVO::getInfoMaturityEmbedded).max((is, iss) -> is.compareTo(iss)).get()
        String s = students.stream().map(Student::getNameTwo).max((is, iss) -> is.compareTo(iss)).get();
        System.out.println("student: "+s);

        List<String> projectCodeList = new ArrayList<>();
       /* projectCodeList.add("23");projectCodeList.add("90");projectCodeList.add("909");
        String codeStr = "'" + String.join("','", projectCodeList) + "'";
        System.out.print(codeStr);
        Integer one = 557001003;
        System.out.println(one);*/
        System.out.println("two: "+projectCodeList.get(0));




    }
}
